<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //字符串的创建
    var str1 = " hello ";
    var str2 = new String("hello");
    
    //计算字符串的长度
    console.log(str1.length);

    //指定位置的字符
    console.log(str1.charAt(1));

    //检查字符串,字符存在返回1，不存在则返回-1
    console.log(str1.indexOf("g"));

    //去除字符串两边的空格
    console.log(str1.trim());

    //提取字符串中两个指定的索引号之间的字符
    console.log(str1.substring(3,5));
</script>
</html>